//------------------------------------------------------------
//  Filename: motor_wraper.v
//   
//  Author  : wlduan@gmail.com
//  Revise  : 2016-10-09 17:51
//  Description: 
//   
//  Copyright (C) 2014, YRBD, Inc.                      
//  All Rights Reserved.                                       
//-------------------------------------------------------------
//
`timescale 1ns/1ps
 
module MOTOR_WRAPPER(
    input  wire         motor_clk,
    input  wire         reset_n,

    input  wire [31:0]  motor_speed,
    input  wire [31:0]  motor_ctrl_l,
    input  wire [31:0]  motor_ctrl_r,
    input  wire [31:0]  motor_ctrl_x,
    input  wire [31:0]  motor_ctrl_y,

    input  wire [31:0]  motor_move_l,
    input  wire [31:0]  motor_move_r,
    input  wire [31:0]  motor_move_x,
    input  wire [31:0]  motor_move_y,

	output wire         force_pause_l,
	output wire         force_pause_r,
	output wire         force_pause_x,
	output wire         force_pause_y,

    output wire [3:0]   phase_l,
    output wire [3:0]   phase_r,
    output wire [3:0]   phase_x,
    output wire [3:0]   phase_y
);
//--------------------------------------------------------
wire [15:0]  pspeed  = motor_speed[15:0];
wire [15:0]  jspeed  = motor_speed[31:16];
//--------------------------------------------------------
wire clk = motor_clk;
wire rst = ~reset_n;
//--------------------------------------------------------
motor_driver  motor_driver_inst0(
    .clk        ( clk           ) ,
    .rst        ( rst           ) ,

    .speed_base ( pspeed        ) ,
    .motor_ctrl ( motor_ctrl_l  ) ,
    .motor_move ( motor_move_l  ) ,
	 .force_pause( force_pause_l ) ,
    .phase      ( phase_l       ) 
);

motor_driver  motor_driver_inst1(
    .clk        ( clk           ) ,
    .rst        ( rst           ) ,

    .speed_base ( jspeed        ) ,
    .motor_ctrl ( motor_ctrl_x  ) ,
    .motor_move ( motor_move_x  ) ,    
	 .force_pause( force_pause_x ) ,
    .phase      ( phase_x       ) 
);


motor_driver  motor_driver_inst2(
    .clk        ( clk           ) ,
    .rst        ( rst           ) ,

    .speed_base ( pspeed        ) ,
    .motor_ctrl ( motor_ctrl_r  ) ,
    .motor_move ( motor_move_r  ) ,    
	 .force_pause( force_pause_r ) ,
    .phase      ( phase_r       ) 
);


motor_driver  motor_driver_inst3(
    .clk        ( clk           ) ,
    .rst        ( rst           ) ,

    .speed_base ( jspeed        ) ,
    .motor_ctrl ( motor_ctrl_y  ) ,
    .motor_move ( motor_move_y  ) ,    
	 .force_pause( force_pause_y ) ,
    .phase      ( phase_y       ) 
);

endmodule
